# 函数参数
def greet_user(name):
    """
    显示问候语
    :param name:
    :return:
    """
    print(f"Hello, {name.title()} !")


greet_user("John")


# 位置实参
def describe_pet(animal_type='dog', pet_name=''):
    """
    显⽰宠物的信息
    """
    print(f"\nI have a {animal_type}.")
    print(f"My {animal_type}'s name is {pet_name.title()}.")


describe_pet('hamster', 'harry')

describe_pet(animal_type='hamster', pet_name='harry')
describe_pet(pet_name='hamster', animal_type='harry')


# 返回字典
def build_person(first_name, last_name, age=None):
    """返回一个字典 其中包含有关一个人的信息"""
    person = {'first': first_name, 'last': last_name}
    if age:
        person['age'] = age
    return person


musician = build_person('Jimi', 'hendrix', age=27)
print(musician)


# 结合使⽤函数和while循环
# def get_formatted_name(first_name, last_name):
#     """返回规范格式的姓名"""
#     first_name = f"{first_name} {last_name}"
#     return first_name.title()
#
#
# while True:
#     print("\nPlease tell me your name:")
#     print("(enter 'q' at any time to quit)")
#     f_name = input("first name: ")
#     if f_name == 'q':
#         break
#
#     l_name = input("last name: ")
#     if l_name == 'q':
#         break
#
#     formatted_name = get_formatted_name(f_name, l_name)
#     print(f"\nhello, {formatted_name}!")

# 禁⽌函数修改列
def print_models(unprinted_designs, completed_models):
    """
模拟打印每个设计，直到没有未打印的设计为⽌
打印每个设计后，都将其移到列表completed_models中
    """
    while unprinted_designs:
        current_design = unprinted_designs.pop()
        print(f"Printing model: {current_design}")
        completed_models.append(current_design)


def show_completed_models(completed_models):
    """显⽰打印好的所有模型"""
    print("\nThe following models have been printed:")
    for completed_model in completed_models:
        print(completed_model)


unprinted_designs = ['phone case', 'robot pendant', 'dodecahedron']
completed_models = []

# print_models(unprinted_designs, completed_models)
# show_completed_models(completed_models)
print_models(unprinted_designs[:], completed_models)
print(unprinted_designs)

